home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.0 / stk-3 / blt-for-STk-3.0 / blt-1.9 / src / bltWin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-01  |  3.3 KB  |  105 lines

  1. /*
  2.  * bltWin.c --
  3.  *
  4.  *    This module implements simple window commands for
  5.  *    the Tk toolkit.
  6.  *
  7.  * Copyright 1993-1994 by AT&T Bell Laboratories.
  8.  * Permission to use, copy, modify, and distribute this software
  9.  * and its documentation for any purpose and without fee is hereby
  10.  * granted, provided that the above copyright notice appear in all
  11.  * copies and that both that the copyright notice and warranty
  12.  * disclaimer appear in supporting documentation, and that the
  13.  * names of AT&T Bell Laboratories any of their entities not be used
  14.  * in advertising or publicity pertaining to distribution of the
  15.  * software without specific, written prior permission.
  16.  *
  17.  * AT&T disclaims all warranties with regard to this software, including
  18.  * all implied warranties of merchantability and fitness.  In no event
  19.  * shall AT&T be liable for any special, indirect or consequential
  20.  * damages or any damages whatsoever resulting from loss of use, data
  21.  * or profits, whether in an action of contract, negligence or other
  22.  * tortuous action, arising out of or in connection with the use or
  23.  * performance of this software.
  24.  *
  25.  */
  26.  
  27. #include "blt.h"
  28.  
  29. #ifndef WINDOW_VERSION
  30. #define WINDOW_VERSION "1.0"
  31. #endif
  32.  
  33. /* ARGSUSED */
  34. static int
  35. WindowCmd(clientData, interp, argc, argv)
  36.     ClientData clientData;    /* Main window of interpreter. */
  37.     Tcl_Interp *interp;        /* Current interpreter. */
  38.     int argc;            /* Number of arguments. */
  39.     char **argv;        /* Argument strings. */
  40. {
  41.     Tk_Window mainWin = (Tk_Window)clientData;
  42.     Tk_Window tkwin;
  43.     char c;
  44.     int length;
  45.  
  46.     if (argc != 3) {
  47.     Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
  48.         " option window\"", (char *)NULL);
  49.     return TCL_ERROR;
  50.     }
  51.     tkwin = Tk_NameToWindow(interp, argv[2], mainWin);
  52.     if (tkwin == NULL) {
  53.     return TCL_ERROR;
  54.     }
  55. #ifdef notdef
  56.     if (!Tk_IsTopLevel(tkwin)) {
  57.     Tcl_AppendResult(interp, "\"", argv[2], "\" is not a top level window",
  58.         (char *)NULL);
  59.     return TCL_ERROR;
  60.     }
  61. #endif
  62.     c = argv[1][0];
  63.     length = strlen(argv[1]);
  64.     if (Tk_WindowId(tkwin) == None) {
  65.     Tk_MakeWindowExist(tkwin);
  66.     }
  67.     if ((c == 'm') && (strncmp(argv[1], "map", length) == 0)) {
  68.     Tk_MapWindow(tkwin);
  69.     } else if ((c == 'u') && (strncmp(argv[1], "unmap", length) == 0)) {
  70.     Tk_UnmapWindow(tkwin);
  71.     } else if ((c == 'l') && (strncmp(argv[1], "lower", length) == 0)) {
  72.     XLowerWindow(Tk_Display(tkwin), Tk_WindowId(tkwin));
  73.     } else if ((c == 'r') && (strncmp(argv[1], "raise", length) == 0)) {
  74.     XRaiseWindow(Tk_Display(tkwin), Tk_WindowId(tkwin));
  75.     } else {
  76.     Tcl_AppendResult(interp, "unknown option \"", argv[1],
  77.         "\": should be lower, map, raise, or unmap", (char *)NULL);
  78.     return TCL_ERROR;
  79.     }
  80.     return TCL_OK;
  81. }
  82.  
  83. int
  84. Blt_WindowInit(interp)
  85.     Tcl_Interp *interp;
  86. {
  87.     Tk_Window tkwin;
  88.  
  89.     if (Blt_FindCmd(interp, "blt_win", (ClientData *)NULL) == TCL_OK) {
  90.     Tcl_AppendResult(interp, "\"blt_win\" command already exists",
  91.         (char *)NULL);
  92.     return TCL_ERROR;
  93.     }
  94.     tkwin = Tk_MainWindow(interp);
  95.     if (tkwin == NULL) {
  96.     Tcl_AppendResult(interp, "\"blt_win\" requires Tk", (char *)NULL);
  97.     return TCL_ERROR;
  98.     }
  99.     Tcl_SetVar2(interp, "blt_versions", "blt_win", WINDOW_VERSION,
  100.     TCL_GLOBAL_ONLY);
  101.     Tcl_CreateCommand(interp, "blt_win", WindowCmd, (ClientData)tkwin,
  102.     (Tcl_CmdDeleteProc *)NULL);
  103.     return TCL_OK;
  104. }
  105.